package com.fms.controllers.form6;

import home.HomePage;
import includes.Sessions;
import classes.Form6;

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Date;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.Model;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class Uniforms2 extends WebPage{
	
	Reader reader = Resources.getResourceAsReader("sqlMapConfig.xml");
	SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
	
	private Model entryNoModel = new Model();
	private Model orgIdModel = new Model();
	private Model typeOfUniformModel = new Model();
	private Model namesModel = new Model();
	private Model dateReceivedModel = new Model();

	public Uniforms2() throws IOException, SQLException
	{
		
		TextField entryNo = new TextField("entryNo", entryNoModel);
		entryNo.setRequired(true);
		
		TextField orgId = new TextField("orgId", orgIdModel);
		orgId.setRequired(true);
		
		TextField typeOfUniform = new TextField("typeOfUniform", typeOfUniformModel);
		typeOfUniform.setRequired(true);
		
		TextField names = new TextField("names", namesModel);
		names.setRequired(true);
		
		TextField dateReceived = new TextField("dateReceived", dateReceivedModel);
		dateReceived.setRequired(true);
		
		
		Form form = new Form("UniformForm");
		
		form.add(new Button("add"){
		
		private static final long serialVersionUID = 1L;

		public void onSubmit(){
			
			try {
					String entryNo = (String) entryNoModel.getObject();
					String orgId= (String) orgIdModel.getObject();
					String typeOfUniform = (String) typeOfUniformModel.getObject();
					String names = (String) namesModel.getObject();
					String dateReceived = (String) dateReceivedModel.getObject();
				
					Form6 f6 = new Form6();
					
				
					
			
			}
			catch (SQLException e){
				 error("Fill up necessary fields");
				 e.printStackTrace();
			  } catch (IOException e) {
				e.printStackTrace();
			}
		}});
		
				
		add(new BookmarkablePageLink("logoutPage", HomePage.class));
		add(new BookmarkablePageLink("home", TreasurerHome.class));
		add(new BookmarkablePageLink("view", PayrollList.class));
		add(new BookmarkablePageLink("manageForms", ManageForms.class));
		
		
		add(new FeedbackPanel("error"));
		
		form.add(date);
		form.add(activity);
		form.add(purpose);
		form.add(approvedBy);
		form.add(disbursedBy);
		
		add(form);
	}

}